//============================================================================
// Name        : Main.cpp
// Author      : David Kadlecek, Ales Fiser
// Version     :
// Copyright   : Your copyright notice
// Description : sequntialClique in C++, Ansi-style
//============================================================================

#include "InputMatrixHolder.h"
#include "Tests.h"
#include "SequentialCore.h"
#include <time.h>

#include "general.h"

using namespace std;

void runMain(string fileName) {
	InputMatrixHolder* inputMatrix = new InputMatrixHolder();
	inputMatrix->readFromFile(fileName);
	SequentialCore* seqCore = new SequentialCore();
	seqCore->loadInputMatrix(inputMatrix);
	int* result;
	//solve
	Task* task = new Task();
	task->createFullTask(inputMatrix->getNumberOfNodes());
	result = seqCore->findClique(task);
	delete task;
	//print
	int size = 0;
	for (int i = 0; i < inputMatrix->getNumberOfNodes(); ++i) {
		cout << result[i] << " ";
		if (result[i] > 0) {
			size++;
		}
	}
	if (r * (float) inputMatrix->getNumberOfNodes() <= size) {
		cout << "reseni je korektni" << endl;
	} else {
		cout << "reseni nesplnuje podminku" << endl;
	}
	delete seqCore;
}

void doTests() {
	Tests* test = new Tests();
	test->runTests();
	delete test;
}

int main(int argc, char **argv) {
	time_t secondsStart, secondsEnd, diff;

	secondsStart = time(NULL);
	printf("started %ld seconds since January 1, 1970 \n", secondsStart);

	string fileName;
	if (argc == 2) {
		fileName = string(argv[1]);
	} else {
		fileName = fileInputConst;
	}
	cout << fileName << endl;
	if (runTestCode) {
		doTests();
	} else {
		runMain(fileName);
	}
	secondsEnd = time(NULL);
	diff = secondsEnd - secondsStart ;
	printf(
			"enddedd %ld seconds since January 1, 1970,  diference is %ld seconds, it is %ld min and %ld sec\n",
			secondsEnd, diff, diff / 60, diff % 60);
	return 0;
}

